package cn.iocoder.an.module.mold.dal.mysql.upkeepcat2item;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.mold.dal.dataobject.upkeepcat2item.UpkeepCat2itemDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.mold.controller.admin.upkeepcat2item.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 模具保养分类项目对照 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface UpkeepCat2itemMapper extends BaseMapperX<UpkeepCat2itemDO> {

    default PageResult<UpkeepCat2itemDO> selectPage(UpkeepCat2itemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UpkeepCat2itemDO>()
                .eqIfPresent(UpkeepCat2itemDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(UpkeepCat2itemDO::getItemId, reqVO.getItemId())
                .betweenIfPresent(UpkeepCat2itemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UpkeepCat2itemDO::getId));
    }


    /**
     * 根据分类ID删除记录
     * @param categoryId 分类ID
     * @return 删除的记录数
     */
    @Delete("DELETE FROM mold_upkeep_cat2item WHERE category_id = #{categoryId}")
    int deleteByCategoryId(@Param("categoryId") Long categoryId);

}